using Microsoft.AspNetCore.Mvc;
using ZR.Model.BaseManage.Dto;
using ZR.Model.BaseManage;
using ZR.Service.BaseManage.IBaseManageService;
using ZR.Admin.WebApi.Filters;

//创建时间：2025-04-20
namespace ZR.Admin.WebApi.Controllers.BaseManage
{
    /// <summary>
    /// agv信息
    /// </summary>
    [Verify]
    [Route("BaseManage/BaseAgv")]
    public class BaseAgvController : BaseController
    {
        /// <summary>
        /// agv信息接口
        /// </summary>
        private readonly IBaseAgvService _BaseAgvService;

        public BaseAgvController(IBaseAgvService BaseAgvService)
        {
            _BaseAgvService = BaseAgvService;
        }

        /// <summary>
        /// 查询agv信息列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("pageList")]
        [ActionPermissionFilter(Permission = "base:agv:list")]
        public IActionResult PageBaseAgv([FromQuery] BaseAgvQueryDto parm)
        {
            var response = _BaseAgvService.GetPageList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询agv信息详情
        /// </summary>
        /// <param name="AgvId"></param>
        /// <returns></returns>
        [HttpGet("{AgvId}")]
        [ActionPermissionFilter(Permission = "base:agv:query")]
        public IActionResult GetBaseAgv(string AgvId)
        {
            var response = _BaseAgvService.GetInfo(AgvId);
            
            var info = response.Adapt<BaseAgvDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加agv信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "base:agv:add")]
        [Log(Title = "agv信息", BusinessType = BusinessType.INSERT)]
        public IActionResult AddBaseAgv([FromBody] BaseAgvDto parm)
        {
            var modal = parm.Adapt<BaseAgv>().ToCreate(HttpContext);

            var response = _BaseAgvService.AddBaseAgv(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新agv信息
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "base:agv:edit")]
        [Log(Title = "agv信息", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateBaseAgv([FromBody] BaseAgvDto parm)
        {
            var modal = parm.Adapt<BaseAgv>().ToUpdate(HttpContext);
            var response = _BaseAgvService.UpdateBaseAgv(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除agv信息
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete")]
        [ActionPermissionFilter(Permission = "base:agv:delete")]
        [Log(Title = "agv信息", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteBaseAgv([FromBody] string[] ids)
        {
            return ToResponse(_BaseAgvService.Delete(ids));
        }

    }
}